let path = require('path');
let HtmlWebpackPlugin = require('html-webpack-plugin')
let CleanWebpackPlugin = require('clean-webpack-plugin')
let CopyWebpackPlugin = require('copy-webpack-plugin')
let webpack = require('webpack')

module.exports = {
  mode: 'production',
  entry: {
    home: './src/index.js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [
          {
            loader: 'babel-loader',
            options: {
              presets:['@babel/preset-env']
            }
          }
        ]
      }
    ]
  },
  output: {
    //[name] home、other分别打包
    filename: '[name].js',
    path: path.resolve(__dirname,'dist')
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './index.html',//选择一个模板
      filename: 'home.html'
    }),
    new CleanWebpackPlugin('./dist'),  //需要传个路径
    new CopyWebpackPlugin([{from: './doc/1.txt'}]),
    new webpack.BannerPlugin('make 2019 by yy') //这句话会出现在每个打包结果的头部（js）
  ]
} 